package com.asking.Controller;

import com.asking.domain.History;
import com.asking.mq.HistoryProducer;
import com.asking.vo.Result;
import org.apache.activemq.command.ActiveMQMapMessage;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.jms.Queue;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


@RestController
@RequestMapping("/history")
public class HistoryController {

    @Resource
    private JmsMessagingTemplate  jmsMessagingTemplate;
    @Resource
    private Queue   queue;
    @Resource
    private  HistoryProducer  historyProducer;
    @PostMapping
    public ResponseEntity<Result>     addHistory(History  history){
        try{
            historyProducer.addHistory(history);
            return   new ResponseEntity<>(HttpStatus.CREATED);
        }catch (Exception  e){
           e.printStackTrace();
           return    new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }

    }

}
